﻿<cfcomponent>
<cfscript>
DB = 'chinalaohu';
</cfscript>


<cffunction name="home" access="remote" returnFormat="json">
  <cfscript>
	j = {"success":"0"};
	/*darktealist0 = 2;
	chinalist0 = 1;
	list = arraynew(1);
	darkteachild = arraynew(1);
	chinachild = arraynew(1);*/
	</cfscript>
<!---瓷器--->
<cfquery datasource="#DB#" name="china">
SELECT
count(1) AS rc
FROM
auction
WHERE
auction.atag > 0 AND
auction.pcid = 1
</cfquery>
  
<!---678新中国瓷--->
<cfquery datasource="#DB#" name="china1">
SELECT
count(1) AS rc
FROM
auction
WHERE
auction.atag > 0 AND
auction.pbid = 4
</cfquery>
<!---手绘彩瓷--->
<cfquery datasource="#DB#" name="china2">
SELECT
count(1) AS rc
FROM
auction
WHERE
auction.atag > 0 AND
auction.pbid = 3
</cfquery>
<!---auction.pcid = 1 AND
chizhi = '手绘彩瓷'--->
<cfquery datasource="#DB#" name="darktea">
SELECT
count(1) AS rc
FROM
auction
WHERE
auction.atag > 0 AND
auction.pcid = 2
</cfquery>
<!---纪念茶--->
<cfquery datasource="#DB#" name="darktea1">
SELECT
count(1) AS rc
FROM
auction
WHERE
auction.atag > 0 AND
auction.pcid2 = 5
</cfquery>
<cfquery datasource="#DB#" name="darktea2">
SELECT
count(1) AS rc
FROM
auction
WHERE
auction.atag > 0 AND
auction.pcid2 = 12
</cfquery>


  
  <cfscript>
	j = {"success":"1",
	"list":[
		{
		"name":"瓷器",
		"key":"cateId",
		"value":"1",
		"child":[
			{
				"name":"全部",
				"key":"cateId",
				"value":"1",
				"count":china.rc
			},
			{
				"name":"稻房藏678新中国瓷",
				"key":"brandId",
				"value":"4",
				"count":china1.rc
			},
			{
				"name":"钲艺廊手绘彩瓷",
				"key":"brandId",
				"value":"3",
				"count":china2.rc
			},
			{
				"name":"土耳其瓷",
				"key":"brandId",
				"value":"5",
				"count":china2.rc
			}				
		]},
		{
		"name":"黑茶",
		"key":"cateId",
		"value":"2",
		"child":[
			{
				"name":"全部",
				"key":"cateId",
				"value":"2",
				"count":darktea1.rc
			},
			{
				"name":"纪念茶",
				"key":"cateId",
				"value":"5",
				"count":darktea1.rc
			},
			{
				"name":"年份茶",
				"key":"cateId",
				"value":"12",
				"count":darktea2.rc
			}	
		]}

	
	]
	};
	
	
	</cfscript>
  
  
  
  
  
<!---<!---黑茶--->
<cfquery datasource="#DB#" name="darkteachild1">
SELECT
pclass,pcid
FROM
pin_class
WHERE
fpcid = 2
ORDER BY pcorder ASC
</cfquery>
<cfif darkteachild1.recordcount gt 0>

<cfscript>
darktealist1 = valuelist(darkteachild1.pcid);
</cfscript>
<cfoutput query="darkteachild1">
<cfinvoke component="cate" method="catecount" returnvariable="catecount" pcid="#pcid#" />
<cfscript>
listjson = {
"name":pclass,
"key":"cateId",
"count":catecount,
"value":pcid
};

arrayappend(darkteachild,listjson);

</cfscript>


</cfoutput>
<cfscript>
darktealist = {
	"name":"黑茶",
	"key":"cateId",
	"value":"2",
	"child":darkteachild
};
arrayappend(list,darktealist);
</cfscript>

</cfif>
<!---瓷器--->
<cfquery datasource="#DB#" name="chinachild1">
SELECT
pclass,pcid
FROM
pin_class
WHERE
fpcid = 1
ORDER BY pcorder ASC
</cfquery>
<cfif chinachild1.recordcount gt 0>

<cfscript>
chinalist1 = valuelist(chinachild1.pcid);
</cfscript>
<cfoutput query="chinachild1">
<cfinvoke component="cate" method="catecount" returnvariable="catecount" pcid="#pcid#" />

<cfscript>

listjson = {
"name":pclass,
"key":"cateId",
"count":catecount,
"value":pcid
};
arrayappend(chinachild,listjson);


</cfscript>


</cfoutput>
<cfscript>
chinalist = {
	"name":"瓷器",
	"key":"cateId",
	"value":"1",
	"child":chinachild
};
arrayappend(list,chinalist);
</cfscript>


</cfif>--->

  <cfscript>
	//j = {"success":"1","list":list};
	
	j = createObject("component",'cfjson').encode(j);
  return j;
	</cfscript>
</cffunction>

<!---分类计数--->
<cffunction name="catecount" access="public" returntype="numeric">
<cfquery datasource="#DB#" name="catecount">
SELECT
count(1) AS rc
FROM
auction
WHERE
atag > 0 AND
pcid = #pcid#
</cfquery>
<cfreturn catecount.rc>
</cffunction>















<!---作废--->
<cffunction name="home1" access="remote" returnFormat="json">
  <cfscript>
	j = {"success":"0"};
	darktealist0 = 2;
	chinalist0 = 1;
	list = arraynew(1);
	darkteachild = arraynew(1);
	chinachild = arraynew(1);
	</cfscript>
<!---黑茶--->
<cfquery datasource="#DB#" name="darkteachild1">
SELECT
pclass,pcid
FROM
pin_class
WHERE
fpcid = 2
ORDER BY pcorder ASC
</cfquery>
<cfif darkteachild1.recordcount gt 0>

<cfscript>
darktealist1 = valuelist(darkteachild1.pcid);
</cfscript>
<cfoutput query="darkteachild1">
<cfinvoke component="cate" method="catecount" returnvariable="catecount" pcid="#pcid#" />
<cfscript>
listjson = {
"name":pclass,
"key":"cateId",
"count":catecount,
"value":pcid
};

arrayappend(darkteachild,listjson);

</cfscript>


</cfoutput>
<cfscript>
darktealist = {
	"name":"黑茶",
	"key":"cateId",
	"value":"2",
	"child":darkteachild
};
arrayappend(list,darktealist);
</cfscript>

</cfif>
<!---瓷器--->
<cfquery datasource="#DB#" name="chinachild1">
SELECT
pclass,pcid
FROM
pin_class
WHERE
fpcid = 1
ORDER BY pcorder ASC
</cfquery>
<cfif chinachild1.recordcount gt 0>

<cfscript>
chinalist1 = valuelist(chinachild1.pcid);
</cfscript>
<cfoutput query="chinachild1">
<cfinvoke component="cate" method="catecount" returnvariable="catecount" pcid="#pcid#" />

<cfscript>

listjson = {
"name":pclass,
"key":"cateId",
"count":catecount,
"value":pcid
};
arrayappend(chinachild,listjson);


</cfscript>


</cfoutput>
<cfscript>
chinalist = {
	"name":"瓷器",
	"key":"cateId",
	"value":"1",
	"child":chinachild
};
arrayappend(list,chinalist);
</cfscript>


</cfif>

  <cfscript>
	j = {"success":"1","list":list};
	
	j = createObject("component",'cfjson').encode(j);
  return j;
	</cfscript>
</cffunction>

</cfcomponent>